package cn.itrip.common;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5Util {
    public static String encode(String oldValue)  {
        try {
            MessageDigest md5 =MessageDigest.getInstance("md5");
            byte [] bs= md5.digest(oldValue.getBytes());//utf-8  3
            int c=0;
            StringBuilder sb=new StringBuilder();
            for(byte b :bs){
                c=b;
                if(c<0){
                    c+=256;
                }
                sb.append(Integer.toHexString(c));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        encode("123457");
    }
}
